from numpy import * 


def logposv(x):
    x_pos = where(x > 0, log(x), 0) # subst. negative values by 1
    return x_pos
ind = arange(10) - 5

def proba(p,j):
    return where(j!=p,divide(1,j-p),0)

print proba(1,1)
#print fromfunction(proba,(3,3))


 
n = 10.0
'''def f(p,phi):
    return cos(p*phi)
def Int(p):   
    phi = arange(n)/n
    def ff(p,j): return f(p,phi[j])   
    a = fromfunction(f,(p-1,n-1)) 
    return sum(f(p,phi),axis = 1)/n
print Int(4)'''

'''def f(p,j,phi):
    return cos((p+j)*phi)
def Int(p,j):   
    m = p+j+1
    phi = arange(m)/m
    def ff(p,j,k): return f(p,j,phi[k])   
    a = fromfunction(ff,(p,j,n-1))    
    return sum(a,axis = 2)/n
print Int(4,3)'''
'''def f(p,j,phi):
    return cos((p+j)*phi)
def Int(p,j):   
    m = p+j+1
    phi = arange(m)/m    
    return sum(f(p,j,phi))/n
print Int(2,3)
print fromfunction(Int,(2,3))
'''
    